<template>
<div>
  <el-menu
    :default-active="activeIndex2"
    router
    class="el-menu-demo"
    mode="horizontal"
    @select="handleSelect"
    background-color="#545c64"
    text-color="#fff"
    active-text-color="#ffd04b">
    <el-menu-item index="/tobase" @click="getlist()">个人基本信息</el-menu-item>
    <el-menu-item index="/tohistory" @click="tohistory()">历史登记信息</el-menu-item>
    <el-menu-item index="/tonow" >当前登记信息</el-menu-item>
  </el-menu>
  <span style="color: red;margin-left: 50%; text-align: center">Hello,{{ userName }} </span>
  <router-view></router-view>

</div>
</template>

<script>
import {Axios as axios} from 'axios'

export default {
  name: 'studentMain',
  data () {
    return {
      userName:'',
      id:'',
      activeIndex: '1',
      activeIndex2: '1'
    }
  },
  mounted () {
    this.userName=this.$store.state.textData
    console.log(this.userName)
  },
  methods: {
    handleSelect (key, keyPath) {
      console.log(key, keyPath)
    },
    tohistory(){
      this.axios.post('http://localhost:8181/user/historyList').then(res=>{
        this.$router.push({
          path:'/tohistory',
          query:{
            table3:res.data
          }
        })
      })
    },
    getlist(){
      let postData=this.$qs.stringify({
        name:encodeURI(this.$store.state.textData)
      });
      this.axios.post('http://localhost:8181/user/list',postData).then(res=>{
        console.log(postData);
        this.$router.push(
          {
            //添加需要传值到那个页面的路径
            path:'/tobase',
            //携带需要传递的参数
            query:{table:res.data}
          })
      })
    }

  },

}
</script>
